GDK W32: Test for IME correctly
authorРуслан Ижбулатов <lrn1986@gmail.com>
Fri, 22 Mar 2019 15:10:02 +0000 (15:10 +0000)
committerРуслан Ижбулатов <lrn1986@gmail.com>
Fri, 22 Mar 2019 16:58:59 +0000 (16:58 +0000)
commit64ab82c403326ae3f457b5bf31622b5ec096b981
tree569a9ce449c341bb32c0f5d6d425b8763707abe6
parent56df49971ad9fe74b02f8251c6805c10626f7cdf
GDK W32: Test for IME correctly

ImmIsIME() doesn't work (always returns TRUE) since Vista.
Use ITfActiveLanguageProfileNotifySink to detect TSF changes,
which are equal to IME changes for us.

Also make sure that IMMultiContext re-loads the IM when keyboard layout
changes, otherwise there's a subtle bug that could happen:
* Run GTK application with non-IME layout (US, for example)
* Focus on an editable widget (GtkEntry, for example)
* IM Context is initialized to use the simple IM
* Switch to an IME layout (such as Korean)
* Start typing
* Since IME module is not loaded yet, keypresses are handled
  by a default MS IME handler
* Once IME commits a character, GDK will get a WM_KEYDOWN,
  which will trigger a GdkKeyEvent, which will be handled by
  an event filter in IM Context, which will finally re-evaluate
  its status and load IME, and only after that GTK will get
  to handle IME by itself - but by that point input would
  already be broken.
To avoid this we can emit a dummy event (with Void keyval),
which will cause IM Context to load the appropriate module
immediately.
gdk/win32/gdkdisplay-win32.c
gdk/win32/gdkevents-win32.c
gdk/win32/gdkglobals-win32.c
gdk/win32/gdkmain-win32.c
gdk/win32/gdkwin32langnotification.c [new file with mode: 0644]
gdk/win32/gdkwin32langnotification.h [new file with mode: 0644]
gdk/win32/meson.build